package com.newsmanagement.controller.backstage;

import com.newsmanagement.entity.NewsContentEntity;
import com.newsmanagement.entity.ReturnedMessages;
import com.newsmanagement.service.INewsContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xbr
 * 2017.12.04 11:24
 * 后台系统 版本更新
 */
@Controller
@RequestMapping("versionUpdateBack")
public class VersionUpdateBackstageController {

    @Autowired
    private INewsContentService newsContentService;


    /**
     * 添加版本信息（包含文件上传）
     * 测试：
     * @param newsContent 新闻内容
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public ReturnedMessages addVersionUpdate(
            @ModelAttribute( "newsContent" ) NewsContentEntity newsContent
    ){

        return null;
        //return newsContentService.addNewsContent(newsContent);
    }

    /**
     * 修改版本信息
     * 测试：
     * @param newsContent 新闻内容
     * @return
     */
    @RequestMapping("update")
    @ResponseBody
    public ReturnedMessages updateVersionUpdate(
            @ModelAttribute( "newsContent" ) NewsContentEntity newsContent
    ){

        System.out.println("newsContent:" + newsContent.toString());
        return newsContentService.updateNewsContent(newsContent);
    }

    /**
     * 删除版本信息
     * 测试：
     * @param contentId 新闻内容id
     * @return
     */
    @RequestMapping("delete")
    @ResponseBody
    public ReturnedMessages deleteVersionUpdate(
            @RequestParam( "contentId" ) Integer contentId
    ){

        System.out.println("contentId:" + contentId);
        return newsContentService.deleteNewsContent(contentId);
    }

    /**
     * 分页查询版本信息列表
     */

}
